package com.datamation.swadeshi.adapter;

import java.util.ArrayList;

import com.datamation.swadeshi.R;
import com.datamation.swadeshi.control.data.ItemsDS;
import com.datamation.swadeshi.model.FTranDet;
import com.datamation.swadeshi.model.OrdDet;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class LoadingDetAdapter extends ArrayAdapter<FTranDet> {
	Context context;
	ArrayList<FTranDet> list;
	
	public LoadingDetAdapter(Context context, ArrayList<FTranDet> list) {
		super(context, R.layout.row_orderfinal_details, list);
		this.context = context;
		this.list = list;	
	}
	@Override
	public View getView(final int position, final View convertView, final ViewGroup parent) {
		
		LayoutInflater inflater = null;
		View row = null;
		
		inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		row = inflater.inflate(R.layout.row_orderfinal_details, parent, false);
		LinearLayout layout = (LinearLayout) row.findViewById(R.id.linearLayout);
		
		TextView item = (TextView) row.findViewById(R.id.row_itemname);
		TextView cases = (TextView) row.findViewById(R.id.row_cases);
		TextView piece = (TextView) row.findViewById(R.id.row_piece);
	
		ItemsDS ds =new ItemsDS(getContext());
		item.setText(ds.getItemNameByCode(list.get(position).getFTRANDET_ITEMCODE()));
		
		cases.setText(list.get(position).getFTRANDET_CASEQTY());
		piece.setText(list.get(position).getFTRANDET_PICEQTY());
		
		return row;
	}
}
